home *** CD-ROM | disk | FTP | other *** search
- #ifndef __STD_IOSBASE__
- #define __STD_IOSBASE__
- #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
-
- /***************************************************************************
- *
- * iosbase - Declarations for the Standard Library basic stream I/O
- *
- * $Id: iosbase,v 1.9 1996/09/20 03:56:46 smithey Exp $
- *
- ***************************************************************************
- *
- * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
- * ALL RIGHTS RESERVED *
- * The software and information contained herein are proprietary to, and
- * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
- * intends to preserve as trade secrets such software and information.
- * This software is furnished pursuant to a written license agreement and
- * may be used, copied, transmitted, and stored only in accordance with
- * the terms of such license and with the inclusion of the above copyright
- * notice. This software and information or any other copies thereof may
- * not be provided or otherwise made available to any other person.
- *
- * Notwithstanding any other lease or license that may pertain to, or
- * accompany the delivery of, this computer software and information, the
- * rights of the Government regarding its use, reproduction and disclosure
- * are as set forth in Section 52.227-19 of the FARS Computer
- * Software-Restricted Rights clause.
- *
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 252.227-7013.
- * Contractor/Manufacturer is Rogue Wave Software, Inc.,
- * P.O. Box 2328, Corvallis, Oregon 97339.
- *
- * This computer software and information is distributed with "restricted
- * rights." Use, duplication or disclosure is subject to restrictions as
- * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
- * Computer Software-Restricted Rights (April 1985)." If the Clause at
- * 18-52.227-74 "Rights in Data General" is specified in the contract,
- * then the "Alternate III" clause applies.
- *
- **************************************************************************/
-
- #ifndef __STD_RWCOMPILER_H__
- #include <stdcomp.h>
- #endif
-
- #ifndef _RWSTD_NO_NEW_HEADER
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #ifndef _RWSTD_NO_WIDE_CHAR
- #include <cwchar>
- #ifndef _RWSTD_NO_WCTYPE_H
- #include <cwctype>
- #endif
- #endif
- #include <cstddef>
- #else
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifndef _RWSTD_NO_WIDE_CHAR
- #ifndef _RWSTD_NO_WCHAR_H
- #include <wchar.h>
- #endif
- #ifndef _RWSTD_NO_WCTYPE_H
- #include <wctype.h>
- #endif
- #endif
- #include <stddef.h>
- #endif
-
- #include <rw/stdmutex.h>
-
- #ifndef _RWSTD_NO_EXCEPTIONS
- #ifdef _RW_STD_EXCEPT
- #include <exception>
- #endif
- #endif
-
- #ifndef _RWSTD_NO_NAMESPACE
- namespace std {
- #endif
-
- typedef long SZ_T;
- typedef SZ_T streamsize;
-
-
- /*
- *
- * CLASS IOS_BASE
- *
- */
-
- class _RWSTDExport ios_base {
-
- public:
-
- #ifndef _RWSTD_NO_EXCEPTIONS
- #ifdef _RW_STD_EXCEPT
- class _RWSTDExport failure : public exception {
-
- public:
- _EXPLICIT failure(const string& msg);
- virtual ~failure() _RWSTD_THROW_SPEC_NULL;
- virtual const char* what() const _RWSTD_THROW_SPEC_NULL;
-
- private:
- string str_;
- };
- #endif
- #endif
-
- typedef int iostate;
-
- enum io_state {
- goodbit = 0x00,
- badbit = 0x01,
- eofbit = 0x02,
- failbit = 0x04
- };
-
- typedef int openmode;
-
- enum open_mode {
- app = 0x01,
- binary = 0x02,
- in = 0x04,
- out = 0x08,
- trunc = 0x10,
- ate = 0x20
- };
-
- typedef int seekdir;
-
- enum seek_dir {
- beg = 0x0,
- cur = 0x1,
- end = 0x2
- };
-
- typedef int fmtflags;
-
- enum fmt_flags {
- boolalpha = 0x0001,
- dec = 0x0002,
- fixed = 0x0004,
- hex = 0x0008,
- internal = 0x0010,
- left = 0x0020,
- oct = 0x0040,
- right = 0x0080,
- scientific = 0x0100,
- showbase = 0x0200,
- showpoint = 0x0400,
- showpos = 0x0800,
- skipws = 0x1000,
- unitbuf = 0x2000,
- uppercase = 0x4000,
- adjustfield = left | right | internal,
- basefield = dec | oct | hex,
- floatfield = scientific | fixed
- };
-
- enum event {
- erase_event = 0x0001,
- imbue_event = 0x0002,
- copyfmt_event = 0x0004
- };
-
- typedef void (*event_callback) (event, ios_base&, int index);
-
- void register_callback( event_callback fn, int index);
-
- class Init {
- static int init_cnt_;
-
- public:
-
- static int getinit_cnt_() { return init_cnt_;}
- Init();
- ~Init();
- };
-
-
- inline fmtflags flags() const;
- inline fmtflags flags(fmtflags fmtfl);
- inline fmtflags setf(fmtflags fmtfl);
- inline fmtflags setf(fmtflags fmtfl, fmtflags mask);
-
- inline void unsetf(fmtflags mask);
-
- ios_base& copyfmt(const ios_base& rhs);
- ios_base& _RW_UNSAFE_copyfmt(const ios_base& rhs);
-
- inline streamsize precision() const;
- inline streamsize precision(streamsize prec);
-
- inline streamsize width() const;
- inline streamsize width(streamsize wide);
-
- static int xalloc();
-
- long& iword(int index);
- void*& pword(int index);
-
- locale imbue(const locale& loc);
- locale getloc() const
- { return loc_; }
-
- bool is_synch()
- { return _sync_with_stdio; }
-
- bool sync_with_stdio(bool sync = true)
- {
- bool tmp = _sync_with_stdio;
- _sync_with_stdio = sync;
- return tmp;
- }
-
- protected:
-
- ios_base();
- ~ios_base();
-
-
- fmtflags fmtfl_;
- streamsize prec_;
- streamsize wide_;
-
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDMutex stream_mutex_;
- #endif
-
- private:
-
- void usersize(int);
-
- locale loc_;
-
- union ios_user_union {
- long lword;
- void *pword;
- };
-
- struct register_call {
- int index_;
- event_callback fn_;
- };
-
-
- static int index_;
- int index_cp_;
- int index_callback_;
- union ios_user_union *userwords_;
- struct register_call *registered_call_;
-
- static bool _sync_with_stdio;
- };
-
-
-
- /*
- *
- * INLINE DEFINITIONS
- *
- */
-
-
- /*
- * fmtflags flags() const
- */
-
- inline ios_base::fmtflags
- ios_base::flags() const
- {
- return fmtfl_;
- }
-
- /*
- * fmtflags flags(fmtflags)
- */
-
- inline ios_base::fmtflags
- ios_base::flags(ios_base::fmtflags flgs)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- ios_base::fmtflags f = fmtfl_;
-
- fmtfl_ = flgs;
-
- return f;
- }
-
- /*
- * fmtflags setf(fmtflags)
- */
-
- inline ios_base::fmtflags
- ios_base::setf(ios_base::fmtflags flgs)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- ios_base::fmtflags f = fmtfl_;
-
- fmtfl_ |= flgs;
-
- return f;
- }
-
- /*
- * fmtflags setf(fmtflags, fmtflags)
- */
-
- inline ios_base::fmtflags
- ios_base::setf(ios_base::fmtflags flgs, ios_base::fmtflags mask)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- ios_base::fmtflags old = fmtfl_;
-
- fmtfl_ &= ~mask;
-
- fmtfl_ |= (flgs & mask);
-
- return old;
- }
-
- /*
- * void unsetf(fmtflags)
- */
-
- inline void
- ios_base::unsetf(ios_base::fmtflags fg)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- fmtfl_ &= ~fg;
- }
-
- /*
- * streamsize precision() const
- */
-
- inline streamsize
- ios_base::precision() const
- {
- return prec_;
- }
-
- /*
- * streamsize precision(streamsize)
- */
-
-
- inline streamsize
- ios_base::precision(streamsize p)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- streamsize temp = prec_;
-
- prec_ = p;
-
- return temp;
- }
-
- /*
- * streamsize width() const
- */
-
- inline streamsize
- ios_base::width() const
- {
- return wide_;
- }
-
- /*
- * streamsize width(streamsize)
- */
-
- inline streamsize
- ios_base::width(streamsize w)
- {
- #ifdef _RWSTD_MULTI_THREAD
- _RWSTDGuard guard(this->stream_mutex_);
- #endif
-
- streamsize i = wide_;
-
- wide_ = w;
-
- return i;
- }
-
-
-
- /*
- *
- * EXTERNAL DECLARATIONS FOR MANIPULATORS
- *
- */
-
- inline ios_base& _RWSTDExport unitbuf(ios_base& strm)
- {
- strm.setf(ios_base::unitbuf);
-
- return strm;
- }
-
- /*
- * unset the unitbuf mode
- */
-
- inline ios_base& _RWSTDExport nounitbuf(ios_base& strm)
- {
- strm.unsetf(ios_base::unitbuf);
-
- return strm;
- }
-
- /*
- * says that bool will be inserted/extracted as
- * false/true depending on locale
- */
-
- inline ios_base& _RWSTDExport boolalpha(ios_base& strm)
- {
- strm.setf(ios_base::boolalpha);
-
- return strm;
- }
-
- /*
- * bool is inserted/extraced as 0/1
- */
-
- inline ios_base& _RWSTDExport noboolalpha(ios_base& strm)
- {
- strm.unsetf(ios_base::boolalpha);
-
- return strm;
- }
-
- /*
- * shows the base of the number e.g. 0777 for oct, 0x for hex
- */
-
- inline ios_base& _RWSTDExport showbase(ios_base& strm)
- {
- strm.setf(ios_base::showbase);
-
- return strm;
- }
-
- /*
- * does not show the base
- */
-
- inline ios_base& _RWSTDExport noshowbase(ios_base& strm)
- {
- strm.unsetf(ios_base::showbase);
-
- return strm;
- }
-
- /*
- * shows the decimal point on floating insertion even if not necessary
- */
-
- inline ios_base& _RWSTDExport showpoint(ios_base& strm)
- {
- strm.setf(ios_base::showpoint);
-
- return strm;
- }
-
- /*
- * does not show the decimal point if not necessary
- */
-
- inline ios_base& _RWSTDExport noshowpoint(ios_base& strm)
- {
- strm.unsetf(ios_base::showpoint);
-
- return strm;
- }
-
- /*
- * prints the sign of the number. will also print '+' for positive #'s
- */
-
- inline ios_base& _RWSTDExport showpos(ios_base& strm)
- {
- strm.setf(ios_base::showpos);
-
- return strm;
- }
-
- /*
- * only shows the sign for negative values
- */
-
- inline ios_base& _RWSTDExport noshowpos(ios_base& strm)
- {
- strm.unsetf(ios_base::showpos);
-
- return strm;
- }
-
- /*
- * skips the white space when reading characters
- */
-
- inline ios_base& _RWSTDExport skipws(ios_base& strm)
- {
- strm.setf(ios_base::skipws);
-
- return strm;
- }
-
- /*
- * doesn't skip white space when reading characters
- */
-
- inline ios_base& _RWSTDExport noskipws(ios_base& strm)
- {
- strm.unsetf(ios_base::skipws);
-
- return strm;
- }
-
- /*
- * prints floating point and hex values in uppercase.
- * e.g. 1.234E05, 0X1B
- */
-
- inline ios_base& _RWSTDExport uppercase(ios_base& strm)
- {
- strm.setf(ios_base::uppercase);
-
- return strm;
- }
-
- /*
- * uses lowercase for floating point and hex values
- */
-
- inline ios_base& _RWSTDExport nouppercase(ios_base& strm)
- {
- strm.unsetf(ios_base::uppercase);
-
- return strm;
- }
-
- inline ios_base& _RWSTDExport internal(ios_base& strm)
- {
- strm.setf(ios_base::internal, ios_base::adjustfield);
-
- return strm;
- }
-
- /*
- * does left justifying
- */
-
- inline ios_base& _RWSTDExport left(ios_base& strm)
- {
- strm.setf(ios_base::left, ios_base::adjustfield);
-
- return strm;
- }
-
- /*
- * does right justifying
- */
-
- inline ios_base& _RWSTDExport right(ios_base& strm)
- {
- strm.setf(ios_base::right, ios_base::adjustfield);
-
- return strm;
- }
-
- /*
- * prints integer values in decimal
- */
-
- inline ios_base& _RWSTDExport dec(ios_base& strm)
- {
- strm.setf(ios_base::dec, ios_base::basefield);
-
- return strm;
- }
-
- /*
- * prints integer values in hexadecimal
- */
-
- inline ios_base& _RWSTDExport hex(ios_base& strm)
- {
- strm.setf(ios_base::hex, ios_base::basefield);
-
- return strm;
- }
-
- /*
- * prints integer values in octal
- */
-
- inline ios_base& _RWSTDExport oct(ios_base& strm)
- {
- strm.setf(ios_base::oct, ios_base::basefield);
-
- return strm;
- }
-
- /*
- * generate floating point numbers in fixed-point notation
- */
-
- inline ios_base& _RWSTDExport fixed(ios_base& strm)
- {
- strm.setf(ios_base::fixed, ios_base::floatfield);
-
- return strm;
- }
-
- /*
- * generates floating-point numbers in scientific notation
- */
-
- inline ios_base& _RWSTDExport scientific(ios_base& strm)
- {
- strm.setf(ios_base::scientific, ios_base::floatfield);
-
- return strm;
- }
- /*
- ios_base& _RWSTDExport boolalpha(ios_base&);
- ios_base& _RWSTDExport noboolalpha(ios_base&);
- ios_base& _RWSTDExport showbase(ios_base&);
- ios_base& _RWSTDExport noshowbase(ios_base&);
- ios_base& _RWSTDExport showpoint(ios_base&);
- ios_base& _RWSTDExport noshowpoint(ios_base&);
- ios_base& _RWSTDExport showpos(ios_base&);
- ios_base& _RWSTDExport noshowpos(ios_base&);
- ios_base& _RWSTDExport skipws(ios_base&);
- ios_base& _RWSTDExport noskipws(ios_base&);
- ios_base& _RWSTDExport uppercase(ios_base&);
- ios_base& _RWSTDExport nouppercase(ios_base&);
- ios_base& _RWSTDExport internal(ios_base&);
- ios_base& _RWSTDExport left(ios_base&);
- ios_base& _RWSTDExport right(ios_base&);
- ios_base& _RWSTDExport dec(ios_base&);
- ios_base& _RWSTDExport hex(ios_base&);
- ios_base& _RWSTDExport oct(ios_base&);
- ios_base& _RWSTDExport fixed(ios_base&);
- ios_base& _RWSTDExport scientific(ios_base&);
- ios_base& _RWSTDExport unitbuf(ios_base&);
- ios_base& _RWSTDExport nounitbuf(ios_base&);
- */
-
- // end inlining
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- #endif
-
- #pragma option pop
- #endif /* __STD_IOSBASE__ */
-